
// 执行js脚本
export const performScriptForFunction = (script, appName, global) => {
  // 代理沙箱
  window.proxy = global
  // console.log(global)
  const scriptText = `
    return ((window) => {
      ${script}
      return window['${appName}']
    })(window.proxy)
  `
  return new Function(scriptText)()
 
  
  // 沙箱快照
  // const scriptText = `
  //   ${script}
  //   return window['${appName}']
  // `
  // return new Function(scriptText).call(global,global)
}

export const performScriptForEval = (script, appName, global) => {
  // library window.appName

  // 代理沙箱
  window.proxy = global
  const scriptText = `
    ((window) => {
      ${script}
      return window['${appName}'] 
    })(window.proxy)
  `
   return eval(scriptText)// app module mount
   
   // 沙箱快照
  // const scriptText = `
  //   () => {
  //     ${script}
  //     return window['${appName}']   // vueconfig.js out/library设置
  //   }
  // `
  // return eval(scriptText).call(global,global) // app module mount
 
}
